package com.wc.算法基础课.F第六讲贪心.三国游戏;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/4/12 14:57
 * @description https://www.acwing.com/problem/content/4968/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] a = new int[N];
    static int[] b = new int[N];
    static int[] c = new int[N];
    static int[] w = new int[N];
    static int n;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) b[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) c[i] = sc.nextInt();

        out.println(Math.max(work(a, b, c), Math.max(work(b, a, c), work(c, a, b))));
        out.flush();
    }

    static int work(int[] a, int[] b, int[] c) {
        for (int i = 1; i <= n; i++) w[i] = a[i] - b[i] - c[i];
        long sum = 0;
        int res = -1;
        Arrays.sort(w, 1, n + 1);
        for (int i = n; i >= 1; i--) {
            sum += w[i];
            if (sum <= 0){
                break;
            } else {
                res = n - i + 1;
            }
        }
        return res;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
